layui.use(['carousel', 'form'], function () {
    var carousel = layui.carousel
        , form = layui.form;
    //设定各种参数
    var ins3 = carousel.render({
        elem: '#test3'
    });
    //事件
    // carousel.on('change(test4)', function(res){
    //     // console.log(res)
    // });
});
layui.use('element', function () {
    var $ = layui.jquery
        , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
})
updatePrice();


/*===========加减游客数量====================*/
function addadultNum() {
    var adultNum = $(".js-adult-num").val();
    adultNum++;
    $(".js-adult-num").val(adultNum);
    updatePrice();
}

function addchildNum() {
    var childNum = $(".js-child-num").val();
    childNum++;
    $(".js-child-num").val(childNum);
    updatePrice();
}

function subadultNum() {
    var adultNum = $(".js-adult-num").val();
    if (adultNum == 0) {
        return false;
    } else {
        adultNum--;
        $(".js-adult-num").val(adultNum);
        updatePrice();
    }
}

function subchildNum() {
    var childNum = $(".js-child-num").val();
    if (childNum == 0) {
        return false;
    } else {
        childNum--;
        $(".js-child-num").val(childNum);
        updatePrice();
    }
}

/*=================价格==================*/

function updatePrice() {
    var Price = $("#js-min-price").html();
    var adultPrice = Price.replace("¥", "") / 1;
    var childPrice = adultPrice / 2;
    var childNum = $(".js-child-num").val();
    var adultNum = $(".js-adult-num").val();
    var sumPrice = adultPrice * adultNum + childNum * childPrice;//总价
    $(".js-order-price").html(sumPrice);
    // console.log("成人价格:" + adultPrice);
    // console.log("儿童价格:" + childPrice);
    // console.log("总价格:" + sumPrice);
}

/*=============跳转确认订单页面===================*/
function confirmOeder() {
    var proID = $(".proId").val();
    var goDate = $(".js-go-date").val();
    var adultNum = $(".js-adult-num").val();
    var childNum = $(".js-child-num").val();
    var Price = $("#js-min-price").html();
    var adultPrice = Price.replace("¥", "") / 1;
    var productName = $(".proName").html();
    var startCity = $(".prostartcity").val();
    var secKillId = $(".secKillId").val();
    var secKillNub = $(".secKillNum").val();
    var nowTime = new Date();
    console.log("出发日期:" + goDate);
    console.log("成人数量" + adultNum);
    console.log("儿童数量:" + childNum);
    console.log("秒杀id:" + secKillId);
    console.log("秒杀剩余数量:" + secKillNub);
    //秒杀id不存在  便是正常购买 直接跳转
    if (secKillId == "" || secKillId == null) {

        location.href = "/product/confirmorder?proId=" + proID + "&goDate=" +
            goDate + "&adultNum=" + adultNum + "&childNum=" + childNum +
            "&adultPrice=" + adultPrice + "&proName=" + productName + "&satrtCity=" + startCity;
    } else {
        checkSecKill(secKillId);
    }

}

//检查是否能够秒杀
function checkSecKill(seckillid) {
    $.ajax({
        type: 'get',
        url: '/seckill/confirmrush',
        datatype: 'json',
        data:"seckillId="+seckillid,
        success:function (dataResult) {
            console.log(dataResult);
            console.log(dataResult.message);
           if(dataResult.data==false){
               layer.open({
                   title: '筋斗秒杀'
                   , content: dataResult.message
               });
           }else {
               var proID = $(".proId").val();
               var goDate = $(".js-go-date").val();
               var adultNum = $(".js-adult-num").val();
               var childNum = $(".js-child-num").val();
               var Price = $("#js-min-price").html();
               var adultPrice = Price.replace("¥", "") / 1;
               var productName = $(".proName").html();
               var startCity = $(".prostartcity").val();
               var secKillId = $(".secKillId").val();
               var rushTime=new Date().getTime();

               location.href = "/product/confirmorder?proId=" + proID + "&goDate=" +
                   goDate + "&adultNum=" + adultNum + "&childNum=" + childNum + "&adultPrice="
                   + adultPrice + "&proName=" + productName + "&satrtCity=" +
                   startCity+"&rushTime="+rushTime+"&secKillId="+secKillId;
           }
        }
    })

}


/*==================评论===========================*/
allReview(1);

function allReview(pageNum) {
    $.ajax({
        type: "GET",
        dataType: "json",
        data: "page=" + pageNum,
        url: "/review/getByPage",
        success: function (jsonResult) {

            // console.log(jsonResult);

            if (jsonResult.status == 1) {
                // $(".all_num").css("display","block");

                var list = jsonResult.data.list;

                for (var i = 0; i < list.length; i++) {

                    //pageNumber  当前页
                    /*  var pages = jsonResult.data.pages;//总页码
                      var total = jsonResult.data.total;//总个数
                      var prePage = jsonResult.data.prePage;//上一页
                      var nextPage = jsonResult.data.nextPage;//下一页

                      $(".all_pageNum").text(pageNum);
                      $(".all_pages").text(pages);
                      $(".all_total").text(total);*/


                    var productReviewImages = list[i].productReviewImages;

                    var productReview = list[i].productReview;

                    if (productReviewImages != null && productReview.productReviewType == "好评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";


                        var middle = "";
                        for (var a = 0; a < productReviewImages.length; a++) {
                            var images = "                                                                <li><img\n" +
                                "                                                                        src=\"" + productReviewImages[a].url + "\"\n" +
                                "                                                                        width=\"48\" height=\"48\"></li>\n";
                            middle += images;

                        }
                        var good = start + middle + end;
                        // $(".all").text("")
                        $(".all").append(good)
                    } else if (productReviewImages == null && productReview.productReviewType == "好评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";

                        var good = start + end;
                        //    $(".all").text("")
                        $(".all").append(good)
                    } else if (productReviewImages != null && productReview.productReviewType == "中评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";


                        var middle = "";
                        for (var a = 0; a < productReviewImages.length; a++) {
                            var images = "                                                                <li><img\n" +
                                "                                                                        src=\"" + productReviewImages[a].url + "\"\n" +
                                "                                                                        width=\"48\" height=\"48\"></li>\n";
                            middle += images;

                        }
                        var medium = start + middle + end;
                        //  $(".all").text("")
                        $(".all").append(medium)
                    } else if (productReviewImages == null && productReview.productReviewType == "中评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";
                        var medium = start + end;
                        //   $(".all").text("")
                        $(".all").append(medium)
                    } else if (productReviewImages != null && productReview.productReviewType == "差评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";


                        var middle = "";
                        for (var a = 0; a < productReviewImages.length; a++) {
                            var images = "                                                                <li><img\n" +
                                "                                                                        src=\"" + productReviewImages[a].url + "\"\n" +
                                "                                                                        width=\"48\" height=\"48\"></li>\n";
                            middle += images;

                        }
                        var bad = start + middle + end;
                        //    $(".all").text("")
                        $(".all").append(bad)
                    } else if (productReviewImages == null && productReview.productReviewType == "差评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";

                        var bad = start + end;
                        //   $(".all").text("")
                        $(".all").append(bad)


                    }

                    /*        if (pageNum > 1) {
                                $(".all_previous_Page").css("display","block");
                                var hrefVal = "javascript:allReview(" + (prePage) + ");";
                                $(".all_previous_Page").attr("href",hrefVal);
                            } else {
                                $(".all_previous_Page").css("display","none");
                            }

                            if (pageNum < pages) {
                                $(".all_next_Page").css("display","block");
                                var hrefVal = "javascript:allReview(" + (nextPage) + ");";
                                $(".all_next_Page").attr("href",hrefVal);
                            } else {
                                $(".all_next_Page").css("display","none");
                            }*/
                }
                /*        }else {
                            $(".all_msg").text(jsonResult.data);
                            $(".all_num").css("display","none");*/
            }


        }
    })
}

var all = document.querySelector(".all");
// console.log(all)
all.onclick = function (event) {
    var ele = event.target;

    if (ele.nodeName == 'I' && ele.className == 'zan') {
        ele.className = 'zan_ok';
        var id = ele.nextElementSibling.value;

        $.ajax({
            type: "GET",
            url: "/addReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {


                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".bad").text("");
                $(".good").text("");
                $(".medium").text("");
                $(".hasPhoto").text("");

                mediumReview(1);
                hasPhotoReview(1);

                goodReview(1);
                badReview(1);
            }
        })
    } else if (ele.nodeName == 'I' && ele.className == 'zan_ok') {
        ele.className = 'zan';
        var id = ele.nextElementSibling.value;

        $.ajax({
            type: "GET",
            url: "/reduceReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {
                // console.log(jsonResult)

                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".bad").text("");
                $(".good").text("");
                $(".medium").text("");
                $(".hasPhoto").text("");

                mediumReview(1);
                hasPhotoReview(1);

                goodReview(1);
                badReview(1);

            }
        })
    }

}

goodReview(1);

function goodReview(pageNum) {
    $.ajax({
        type: "GET",
        dataType: "json",
        data: "page=" + pageNum,
        url: "/review/getByPage",
        success: function (jsonResult) {

            // console.log(jsonResult);

            if (jsonResult.status == 1) {

                var list = jsonResult.data.list;

                for (var i = 0; i < list.length; i++) {
                    var productReviewImages = list[i].productReviewImages;
                    var productReview = list[i].productReview;
                    if (productReviewImages != null && productReview.productReviewType == "好评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";


                        var middle = "";
                        for (var a = 0; a < productReviewImages.length; a++) {
                            var images = "                                                                <li><img\n" +
                                "                                                                        src=\"" + productReviewImages[a].url + "\"\n" +
                                "                                                                        width=\"48\" height=\"48\"></li>\n";
                            middle += images;

                        }
                        var good = start + middle + end;
                        // $(".all").text("")
                        $(".good").append(good)
                    } else if (productReviewImages == null && productReview.productReviewType == "好评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";

                        var good = start + end;
                        //    $(".all").text("")
                        $(".good").append(good)
                    }
                }
            }
        }
    })
}

var good = document.querySelector(".good");

good.onclick = function (event) {
    var ele = event.target;

    if (ele.nodeName == 'I' && ele.className == 'zan') {
        ele.className = 'zan_ok';
        var id = ele.nextElementSibling.value;

        $.ajax({
            type: "GET",
            url: "/addReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {
                // console.log(jsonResult)

                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".bad").text("")
                $(".all").text("")
                $(".medium").text("")
                $(".hasPhoto").text("")
                allReview(1);
                mediumReview(1);
                hasPhotoReview(1);
                badReview(1);
            }
        })
    } else if (ele.nodeName == 'I' && ele.className == 'zan_ok') {
        ele.className = 'zan';
        var id = ele.nextElementSibling.value;

        $.ajax({
            type: "GET",
            url: "/reduceReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {
                // console.log(jsonResult)

                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".bad").text("")
                $(".all").text("")
                $(".medium").text("")
                $(".hasPhoto").text("")
                allReview(1);
                mediumReview(1);
                hasPhotoReview(1);
                badReview(1);
            }
        })
    }

}
mediumReview(1)

function mediumReview(pageNum) {
    $.ajax({
        type: "GET",
        dataType: "json",
        data: "page=" + pageNum,
        url: "/review/getByPage",
        success: function (jsonResult) {

            // console.log(jsonResult);

            if (jsonResult.status == 1) {
                // $(".all_num").css("display","block");
                var list = jsonResult.data.list;
                for (var i = 0; i < list.length; i++) {
                    var productReviewImages = list[i].productReviewImages;
                    var productReview = list[i].productReview;
                    if (productReviewImages != null && productReview.productReviewType == "中评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";

                        var middle = "";
                        for (var a = 0; a < productReviewImages.length; a++) {
                            var images = "                                                                <li><img\n" +
                                "                                                                        src=\"" + productReviewImages[a].url + "\"\n" +
                                "                                                                        width=\"48\" height=\"48\"></li>\n";
                            middle += images;
                        }
                        var medium = start + middle + end;
                        //  $(".all").text("")

                        $(".medium").append(medium)

                    } else if (productReviewImages == null && productReview.productReviewType == "中评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";
                        var medium = start + end;
                        //   $(".all").text("")

                        $(".medium").append(medium)
                    }
                }
            }
        }
    })
}

var medium = document.querySelector(".medium");

medium.onclick = function (event) {
    var ele = event.target;

    if (ele.nodeName == 'I' && ele.className == 'zan') {
        ele.className = 'zan_ok';
        var id = ele.nextElementSibling.value;

        $.ajax({
            type: "GET",
            url: "/addReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {


                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".bad").text("")
                $(".all").text("")
                $(".good").text("")
                $(".hasPhoto").text("")
                allReview(1);
                goodReview(1);
                hasPhotoReview(1);
                badReview(1);
            }
        })
    } else if (ele.nodeName == 'I' && ele.className == 'zan_ok') {
        ele.className = 'zan';
        var id = ele.nextElementSibling.value;

        $.ajax({
            type: "GET",
            url: "/reduceReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {


                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".bad").text("")
                $(".all").text("")
                $(".good").text("")
                $(".hasPhoto").text("")
                allReview(1);
                goodReview(1);
                hasPhotoReview(1);
                badReview(1);
            }
        })
    }

}
badReview(1)

function badReview(pageNum) {
    $.ajax({
        type: "GET",
        dataType: "json",
        data: "page=" + pageNum,
        url: "/review/getByPage",
        success: function (jsonResult) {

            // console.log(jsonResult);

            if (jsonResult.status == 1) {
                // $(".all_num").css("display","block");
                // console.log(jsonResult.data.list);
                var list = jsonResult.data.list;

                for (var i = 0; i < list.length; i++) {

                    var productReviewImages = list[i].productReviewImages;
                    // console.log(productReviewImages)
                    var productReview = list[i].productReview;
                    // console.log(productReview)
                    if (productReviewImages != null && productReview.productReviewType == "差评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";

                        // console.log(productReviewImages.length)
                        var middle = "";
                        for (var a = 0; a < productReviewImages.length; a++) {
                            var images = "                                                                <li><img\n" +
                                "                                                                        src=\"" + productReviewImages[a].url + "\"\n" +
                                "                                                                        width=\"48\" height=\"48\"></li>\n";
                            middle += images;
                            // console.log(middle)
                        }
                        var bad = start + middle + end;
                        //    $(".all").text("")

                        $(".bad").append(bad)
                    } else if (productReviewImages == null && productReview.productReviewType == "差评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";

                        var bad = start + end;
                        //   $(".all").text("")

                        $(".bad").append(bad)

                    }
                }
            }
        }
    })
}

var bad = document.querySelector(".bad");
// console.log(bad)
bad.onclick = function (event) {
    var ele = event.target;
    // console.log(ele);
    // console.log(ele.nodeName);
    // console.log(ele.className)
    if (ele.nodeName == 'I' && ele.className == 'zan') {
        ele.className = 'zan_ok';
        var id = ele.nextElementSibling.value;
        // console.log(id)
        $.ajax({
            type: "GET",
            url: "/addReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {
                // console.log(jsonResult)

                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".medium").text("")
                $(".all").text("")
                $(".good").text("")
                $(".hasPhoto").text("")
                allReview(1);
                goodReview(1);
                hasPhotoReview(1);
                mediumReview(1);
            }
        })
    } else if (ele.nodeName == 'I' && ele.className == 'zan_ok') {
        ele.className = 'zan';
        var id = ele.nextElementSibling.value;
        // console.log(id)
        $.ajax({
            type: "GET",
            url: "/reduceReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {
                // console.log(jsonResult)

                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".medium").text("")
                $(".all").text("")
                $(".good").text("")
                $(".hasPhoto").text("")
                allReview(1);
                goodReview(1);
                hasPhotoReview(1);
                mediumReview(1);
            }
        })
    }

}
hasPhotoReview(1)

function hasPhotoReview(pageNum) {
    $.ajax({
        type: "GET",
        dataType: "json",
        data: "page=" + pageNum,
        url: "/review/getByPage",
        success: function (jsonResult) {

            // console.log(jsonResult);

            if (jsonResult.status == 1) {
                // $(".all_num").css("display","block");
                // console.log(jsonResult.data.list);
                var list = jsonResult.data.list;
                // console.log(list);
                for (var i = 0; i < list.length; i++) {

                    //pageNumber  当前页
                    /*  var pages = jsonResult.data.pages;//总页码
                      var total = jsonResult.data.total;//总个数
                      var prePage = jsonResult.data.prePage;//上一页
                      var nextPage = jsonResult.data.nextPage;//下一页

                      $(".all_pageNum").text(pageNum);
                      $(".all_pages").text(pages);
                      $(".all_total").text(total);*/


                    var productReviewImages = list[i].productReviewImages;
                    // console.log(productReviewImages)
                    var productReview = list[i].productReview;
                    // console.log(productReview)
                    if (productReviewImages != null && productReview.productReviewType == "好评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">非常满意</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";


                        // console.log(productReviewImages.length)
                        var middle = "";
                        for (var a = 0; a < productReviewImages.length; a++) {
                            var images = "                                                                <li><img\n" +
                                "                                                                        src=\"" + productReviewImages[a].url + "\"\n" +
                                "                                                                        width=\"48\" height=\"48\"></li>\n";
                            middle += images;
                            // console.log(middle)
                        }
                        var good = start + middle + end;
                        // $(".all").text("")


                        $(".hasPhoto").append(good)
                    } else if (productReviewImages != null && productReview.productReviewType == "中评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉一般</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";


                        // console.log(productReviewImages.length)
                        var middle = "";
                        for (var a = 0; a < productReviewImages.length; a++) {
                            var images = "                                                                <li><img\n" +
                                "                                                                        src=\"" + productReviewImages[a].url + "\"\n" +
                                "                                                                        width=\"48\" height=\"48\"></li>\n";
                            middle += images;
                            // console.log(middle)
                        }
                        var medium = start + middle + end;
                        //  $(".all").text("")
                        $(".all").append(medium)
                        $(".medium").append(medium)
                        $(".hasPhoto").append(medium)
                    } else if (productReviewImages != null && productReview.productReviewType == "差评") {
                        var start = "    <div class=\"item cf\">\n" +
                            "                                                <div class=\"m_col_master\">\n" +
                            "                                                    <div class=\"m_rate_grade\">\n" +
                            "                                                        <span class=\"m_score m_score_tag\"><em\n" +
                            "                                                                class=\"num\">" + productReview.productReviewStar + "</em>星</span>\n" +
                            "                                                        <div class=\"m_grade_box\">\n" +
                            "                                                            <div class=\"m_grade_info\">\n" +
                            "                                                                <ul>\n" +
                            "                                                                    <li>行程安排<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>综合服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>餐食质量<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>导游服务<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                    <li>住宿体验<span class=\"m_score\"><em\n" +
                            "                                                                            class=\"num\">感觉很差</em></span></li>\n" +
                            "                                                                </ul>\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                    </div>\n" +
                            "                                                    <div class=\"m_rate_content\">\n" +
                            "                                                        <div class=\"m_rate_fulltxt\">\n" +
                            "                                                            <div class=\"m_rate_label\">【总体感受】</div>\n" +
                            "                                                            <div>\n" +
                            "                                                                " + productReview.productReviewContent + "\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_photos\">\n" +
                            "                                                            <ul class=\"m_rate_photos_thumb cf\">\n";

                        var end = "                                                            </ul>\n" +
                            "                                                            <div class=\"m_rate_photos_viewer\">\n" +
                            "                                                            </div>\n" +
                            "                                                        </div>\n" +
                            "                                                        <div class=\"m_rate_date\"><span\n" +
                            "                                                                class=\"date\">2019-08-20 10:18:07</span><span\n" +
                            "                                                                class=\"source\">来自筋斗云官方网站</span>\n" +
                            "                                                            <i class=\"zan\"></i>\n" +
                            "                                                   <input class='id' type='hidden' value='" + productReview.id + "'>\n" +
                            "                                                            <span class=\"counts\">" + productReview.agreeCount + "</span>\n" +
                            "\n" +
                            "                                                        </div>\n" +
                            "\n" +
                            "                                                    </div>\n" +
                            "                                                </div>\n" +
                            "                                            </div>";

                        // console.log(productReviewImages.length)
                        var middle = "";
                        for (var a = 0; a < productReviewImages.length; a++) {
                            var images = "                                                                <li><img\n" +
                                "                                                                        src=\"" + productReviewImages[a].url + "\"\n" +
                                "                                                                        width=\"48\" height=\"48\"></li>\n";
                            middle += images;
                            // console.log(middle)
                        }
                        var bad = start + middle + end;
                        //    $(".all").text("")


                        $(".hasPhoto").append(bad)
                    }


                }

            }
        }
    })
}

var hasPhoto = document.querySelector(".hasPhoto");
// console.log(hasPhoto)
hasPhoto.onclick = function (event) {
    var ele = event.target;
    // console.log(ele);
    // console.log(ele.nodeName);
    // console.log(ele.className)
    if (ele.nodeName == 'I' && ele.className == 'zan') {
        ele.className = 'zan_ok';
        var id = ele.nextElementSibling.value;
        // console.log(id)
        $.ajax({
            type: "GET",
            url: "/addReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {
                // console.log(jsonResult)

                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".medium").text("")
                $(".all").text("")
                $(".good").text("")
                $(".bad").text("")
                allReview(1);
                goodReview(1);
                badReview(1);
                mediumReview(1);
            }
        })
    } else if (ele.nodeName == 'I' && ele.className == 'zan_ok') {
        ele.className = 'zan';
        var id = ele.nextElementSibling.value;
        // console.log(id)
        $.ajax({
            type: "GET",
            url: "/reduceReviewCount",
            data: "id=" + id,
            datatype: "json",
            success: function (jsonResult) {
                // console.log(jsonResult)

                ele.nextElementSibling.nextElementSibling.innerText = jsonResult.data.agreeCount
                $(".medium").text("")
                $(".all").text("")
                $(".good").text("")
                $(".bad").text("")
                allReview(1);
                goodReview(1);
                badReview(1);
                mediumReview(1);
            }
        })
    }

}

//点击名称进入首页
$(".nav_userName").click(function () {

    $.ajax({
        url: "/order/getId",
        type: "GET",
        datatype: "json",
        success: function (data) {
            console.log(data.data)
            window.sessionStorage.setItem("cusid", data.data)
            $(location).attr('href', 'order');
        }

    })

});